var netcore = require('../../../utils/network.js')
var tripleDes = require('../../../utils/CKCrypto.js')

function invokeSearch(keyWord,pageIndex,callBack){
  var map=new Map()
  map.set("keyword", tripleDes.enCode(keyWord))
  map.set("currentPage", pageIndex)
  netcore.requestPost("search/searchCourses.do",map,function(result){
    result.forEach(function(item,index){
      item.courseNo1 = tripleDes.deCode(item.courseNo1)
      item.courseText = tripleDes.deCode(item.courseText)
      item.courseCover = tripleDes.deCode(item.courseCover)
      item.courseStatusText = tripleDes.deCode(item.courseStatusText)
      item.courseTeacherRealName = tripleDes.deCode(item.courseTeacherRealName)
      item.projectEditionText = tripleDes.deCode(item.projectEditionText) 
      item.projectTypeText = tripleDes.deCode(item.projectTypeText) 
      item.gradeLevelText = tripleDes.deCode(item.gradeLevelText)
    })
    callBack(result)  
  }, function (errorCode, errMsg){
    wx.showToast({
      title: errMsg,
      icon: 'none',
    })
  })
}
module.exports = {
  invokeSearch: invokeSearch
}